using System;
using System.Collections.Generic;
using System.Text;

namespace TidhiGanitam.DataModel
{
    public static class SaliVahanaSakam
    {
        #region Constants for Varam Tidhi Set
        public static VaramTidhiItem ZeroYear = new VaramTidhiItem(
                                                        new Varam(1, 10, 10),
                                                        new Tidhi(12, 45, 14));
        public static VaramTidhiItem[] DigitYear = new VaramTidhiItem[]
            {
                new VaramTidhiItem(new Varam(1,15,31), new Tidhi(11,3,53,24)),  
                new VaramTidhiItem(new Varam(2,31,3), new Tidhi(22,7,46,42)),
                new VaramTidhiItem(new Varam(3,46,35), new Tidhi(3,11,40,6)),
                new VaramTidhiItem(new Varam(5,2,6), new Tidhi(14,15,33,30)),
                new VaramTidhiItem(new Varam(6,17,38), new Tidhi(25,19,26,48)),
                new VaramTidhiItem(new Varam(0,33,09), new Tidhi(6,23,20,12)),
                new VaramTidhiItem(new Varam(1,48,41), new Tidhi(17,27,13,36)),
                new VaramTidhiItem(new Varam(3,4,12), new Tidhi(28,31,6,54)),
                new VaramTidhiItem(new Varam(4,19,44), new Tidhi(9,35,0,18))
            };
        public static VaramTidhiItem[] TensYear = new VaramTidhiItem[]
            {
                new VaramTidhiItem(new Varam(5,35,15), new Tidhi(20,38,53,42)),
                new VaramTidhiItem(new Varam(4,10,31), new Tidhi(11,17,47,30)),
                new VaramTidhiItem(new Varam(2,45,46), new Tidhi(1,56,41,12)),
                new VaramTidhiItem(new Varam(1,21,1), new Tidhi(22,35,34,54)),
                new VaramTidhiItem(new Varam(6,56,16), new Tidhi(13,14,28,42)),
                new VaramTidhiItem(new Varam(5,31,31), new Tidhi(3,53,22,24)),
                new VaramTidhiItem(new Varam(4,6,47), new Tidhi(24,32,16,6)),
                new VaramTidhiItem(new Varam(2,42,2), new Tidhi(15,11,9,48)),
                new VaramTidhiItem(new Varam(1,17,17), new Tidhi(5,50,3,1))
            };
        public static VaramTidhiItem[] HundredYear = new VaramTidhiItem[]
            {
                new VaramTidhiItem(new Varam(6,52,32), new Tidhi(26,28,57,18)),
                new VaramTidhiItem(new Varam(6,45,5), new Tidhi(22,57,54,36)),
                new VaramTidhiItem(new Varam(6,37,37), new Tidhi(19,26,51,54)),
                new VaramTidhiItem(new Varam(6,30,54), new Tidhi(15,55,49,12)),
                new VaramTidhiItem(new Varam(6,22,42), new Tidhi(12,24,46,30)),
                new VaramTidhiItem(new Varam(6,15,14), new Tidhi(8,53,43,42)),
                new VaramTidhiItem(new Varam(6,7,46), new Tidhi(5,22,41,0)),
                new VaramTidhiItem(new Varam(6,0,19), new Tidhi(1,51,38,18)),
                new VaramTidhiItem(new Varam(5,52,51), new Tidhi(28,20,35,36))
            };
        public static VaramTidhiItem[] ThousandYear = new VaramTidhiItem[]
            {
                new VaramTidhiItem(new Varam(5,45,23), new Tidhi(24,49,33,0)),
                new VaramTidhiItem(new Varam(4,30,48), new Tidhi(19,39,6,0))
            };
        public static VaramTidhiItem GetVaramTidhiSet(int Year)
        {
            VaramTidhiItem ReturnValue = new VaramTidhiItem(new Varam(), new Tidhi());
            int ThousandDigit = MathHelper.GetThousandDigit(Year);
            int HundredDigit = MathHelper.GetHundredDigit(Year);
            int TensDigit = MathHelper.GetTensDigit(Year);
            int Digit = MathHelper.GetDigit(Year);
            ReturnValue.VaramItem = ZeroYear.VaramItem;
            ReturnValue.TidhiItem = ZeroYear.TidhiItem;
            if (ThousandDigit > 0)
            {
                ReturnValue.VaramItem += ThousandYear[ThousandDigit-1].VaramItem;
                ReturnValue.TidhiItem += ThousandYear[ThousandDigit - 1].TidhiItem;
            }
            if(HundredDigit > 0)
            {
                ReturnValue.VaramItem += HundredYear[HundredDigit - 1].VaramItem;
                ReturnValue.TidhiItem += HundredYear[HundredDigit - 1].TidhiItem;
            }
            if(TensDigit > 0)
            {
                ReturnValue.VaramItem += TensYear[TensDigit - 1].VaramItem;
                ReturnValue.TidhiItem += TensYear[TensDigit - 1].TidhiItem;
            }
            if (Digit > 0)
            {
                ReturnValue.VaramItem += DigitYear[Digit - 1].VaramItem;
                ReturnValue.TidhiItem += DigitYear[Digit - 1].TidhiItem;
            }
            ReturnValue.TidhiItem.Refresh(); //Refreshes the value
            ReturnValue.VaramItem.Refresh(); //Refreshes the value
            return ReturnValue;
        }

        #endregion

        #region Constants for Ravi Values

        public static RaviItem RaviZeroYear = new RaviItem(new Rasi(11, 20, 46, 6),
                                                        new Rasi(2, 9, 52, 24));

        public static RaviItem[] RaviDigitYear = new RaviItem[]{
            new RaviItem(new Rasi(0,0,1,0),new Rasi(0,0,1,0)),
            new RaviItem(new Rasi(0,0,2,0),new Rasi(0,0,2,0)),
            new RaviItem(new Rasi(0,0,2,54),new Rasi(0,0,3,0)),
            new RaviItem(new Rasi(0,0,3,54),new Rasi(0,0,4,6)),
            new RaviItem(new Rasi(0,0,4,54),new Rasi(0,0,5,6)),
            new RaviItem(new Rasi(0,0,5,54),new Rasi(0,0,6,6)),
            new RaviItem(new Rasi(0,0,6,54),new Rasi(0,0,7,12)),
            new RaviItem(new Rasi(0,0,7,48),new Rasi(0,0,8,12)),
            new RaviItem(new Rasi(0,0,8,48),new Rasi(0,0,9,12)),
        };
        public static RaviItem[] RaviTensYear = new RaviItem[]{
            new RaviItem(new Rasi(0,0,9,48),new Rasi(0,0,10,18)),
            new RaviItem(new Rasi(0,0,19,30),new Rasi(0,0,20,36)),
            new RaviItem(new Rasi(0,0,29,18),new Rasi(0,0,30,54)),
            new RaviItem(new Rasi(0,0,39,0),new Rasi(0,0,41,18)),
            new RaviItem(new Rasi(0,0,48,48),new Rasi(0,0,51,36)),
            new RaviItem(new Rasi(0,0,58,30),new Rasi(0,1,1,54)),
            new RaviItem(new Rasi(0,1,8,18),new Rasi(0,1,12,12)),
            new RaviItem(new Rasi(0,1,18,0),new Rasi(0,1,22,30)),
            new RaviItem(new Rasi(0,1,27,48),new Rasi(0,1,32,48))
        };
        public static RaviItem[] RaviHundredYear = new RaviItem[]{
            new RaviItem(new Rasi(0,1,37,30),new Rasi(0,1,43,12)),
            new RaviItem(new Rasi(0,3,15,6),new Rasi(0,3,26,24)),
            new RaviItem(new Rasi(0,4,52,36),new Rasi(0,5,9,36)),
            new RaviItem(new Rasi(0,6,30,12),new Rasi(0,6,52,42)),
            new RaviItem(new Rasi(0,8,7,42),new Rasi(0,8,35,54)),
            new RaviItem(new Rasi(0,9,45,12),new Rasi(0,10,19,6)),
            new RaviItem(new Rasi(0,11,22,48),new Rasi(0,12,2,18)),
            new RaviItem(new Rasi(0,13,0,18),new Rasi(0,13,45,30)),
            new RaviItem(new Rasi(0,14,37,54),new Rasi(0,15,28,42))
        };
        public static RaviItem[] RaviThousandYear = new RaviItem[]{
            new RaviItem(new Rasi(0,16,15,24),new Rasi(0,17,11,54)),
            new RaviItem(new Rasi(0,2,30,42),new Rasi(1,4,23,48))
        };

        public static RaviItem GetRaviValues(int Year)
        {
            RaviItem ReturnValue = new RaviItem(new Rasi(), new Rasi());
            int ThousandDigit = MathHelper.GetThousandDigit(Year);
            int HundredDigit = MathHelper.GetHundredDigit(Year);
            int TensDigit = MathHelper.GetTensDigit(Year);
            int Digit = MathHelper.GetDigit(Year);
            ReturnValue.MadyamaRavi = RaviZeroYear.MadyamaRavi;
            ReturnValue.RaviMandochha = RaviZeroYear.RaviMandochha;
            if (ThousandDigit > 0)
            {
                ReturnValue.MadyamaRavi += RaviThousandYear[ThousandDigit - 1].MadyamaRavi;
                ReturnValue.RaviMandochha += RaviThousandYear[ThousandDigit - 1].RaviMandochha;
            }
            if (HundredDigit > 0)
            {
                ReturnValue.MadyamaRavi += RaviHundredYear[HundredDigit - 1].MadyamaRavi;
                ReturnValue.RaviMandochha += RaviHundredYear[HundredDigit - 1].RaviMandochha;
            }
            if (TensDigit > 0)
            {
                ReturnValue.MadyamaRavi += RaviTensYear[TensDigit - 1].MadyamaRavi;
                ReturnValue.RaviMandochha += RaviTensYear[TensDigit - 1].RaviMandochha;
            }
            if (Digit > 0)
            {
                ReturnValue.MadyamaRavi += RaviDigitYear[Digit - 1].MadyamaRavi;
                ReturnValue.RaviMandochha += RaviDigitYear[Digit - 1].RaviMandochha;
            }
            ReturnValue.MadyamaRavi.Refresh(); //Refreshes the value
            ReturnValue.RaviMandochha.Refresh(); //Refreshes the value
            return ReturnValue;
        }
        #endregion

        #region Constants for Chandra Values
        public static ChandraItem ChandraZeroYear = new ChandraItem(new Rasi(4,25,42,24), new Rasi(10,19,58,48), new Rasi(4,24,24,54));
        public static ChandraItem[] ChandraDigitYear = new ChandraItem[]{
            new ChandraItem(new Rasi(4,12,47,36), new Rasi(3,2,6,12), new Rasi(0,19,20,30)),
            new ChandraItem(new Rasi(8,25,35,18), new Rasi(6,4,12,18), new Rasi(1,7,41,6)),
            new ChandraItem(new Rasi(1,8,22,54), new Rasi(9,6,18,30), new Rasi(1,28,1,36)),
            new ChandraItem(new Rasi(5,21,10,36), new Rasi(0,8,24,36), new Rasi(2,17,22,6)),
            new ChandraItem(new Rasi(10,3,58,12), new Rasi(3,10,30,48), new Rasi(3,6,42,42)),
            new ChandraItem(new Rasi(2,16,45,54), new Rasi(6,12,37,0), new Rasi(3,26,3,12)),
            new ChandraItem(new Rasi(6,29,33,30), new Rasi(9,14,43,6), new Rasi(4,15,23,48)),
            new ChandraItem(new Rasi(11,12,21,12), new Rasi(0,16,49,18), new Rasi(5,4,44,18)),
            new ChandraItem(new Rasi(3,25,8,48), new Rasi(3,18,55,24), new Rasi(5,24,4,48))
        };
        public static ChandraItem[] ChandraTensYear = new ChandraItem[]{
            new ChandraItem(new Rasi(8,7,56,30), new Rasi(6,21,1,36), new Rasi(6,13,25,24)),
            new ChandraItem(new Rasi(4,15,53,0), new Rasi(1,12,3,6), new Rasi(0,26,50,54)),
            new ChandraItem(new Rasi(0,23,49,30), new Rasi(8,3,4,42), new Rasi(7,10,16,18)),
            new ChandraItem(new Rasi(9,1,46,0), new Rasi(2,24,6,18), new Rasi(1,23,41,48)),
            new ChandraItem(new Rasi(5,9,42,30), new Rasi(9,15,7,54), new Rasi(8,7,7,12)),
            new ChandraItem(new Rasi(1,17,39,0), new Rasi(4,6,9,24), new Rasi(2,20,32,42)),
            new ChandraItem(new Rasi(9,25,35,30), new Rasi(10,27,11,0), new Rasi(9,3,58,6)),
            new ChandraItem(new Rasi(6,3,32,0), new Rasi(5,18,12,36), new Rasi(3,17,23,36)),
            new ChandraItem(new Rasi(2,11,28,30), new Rasi(0,9,14,36), new Rasi(10,0,39,0))
        };
        public static ChandraItem[] ChandraHundredYear = new ChandraItem[]{
            new ChandraItem(new Rasi(10,19,25,0), new Rasi(7,0,15,42), new Rasi(4,14,14,30)),
            new ChandraItem(new Rasi(9,8,50,0), new Rasi(2,0,31,24), new Rasi(8,28,29,0)),
            new ChandraItem(new Rasi(7,28,15,0), new Rasi(9,0,47,12), new Rasi(1,12,43,24)),
            new ChandraItem(new Rasi(6,17,40,0), new Rasi(4,1,2,54), new Rasi(5,26,57,54)),
            new ChandraItem(new Rasi(5,7,5,0), new Rasi(11,1,18,36), new Rasi(10,11,12,24)),
            new ChandraItem(new Rasi(3,26,29,54), new Rasi(6,1,34,18), new Rasi(2,25,26,54)),
            new ChandraItem(new Rasi(2,15,54,54), new Rasi(1,1,50,0), new Rasi(7,9,41,24)),
            new ChandraItem(new Rasi(1,5,19,54), new Rasi(8,2,5,48), new Rasi(11,23,55,48)),
            new ChandraItem(new Rasi(11,24,44,54), new Rasi(3,2,21,30), new Rasi(4,8,10,18))
        };
        public static ChandraItem[] ChandraThousandYear = new ChandraItem[]{
            new ChandraItem(new Rasi(10,14,9,54), new Rasi(10,2,37,12), new Rasi(8,22,24,48)),
            new ChandraItem(new Rasi(8,28,19,54), new Rasi(8,5,14,18), new Rasi(5,14,49,36))
        };
      public static ChandraItem GetChandraValues(int Year)
        {
            ChandraItem ReturnValue = new ChandraItem(new Rasi(), new Rasi(), new Rasi());
            int ThousandDigit = MathHelper.GetThousandDigit(Year);
            int HundredDigit = MathHelper.GetHundredDigit(Year);
            int TensDigit = MathHelper.GetTensDigit(Year);
            int Digit = MathHelper.GetDigit(Year);
            ReturnValue.MadhyamaChandrudu = ChandraZeroYear.MadhyamaChandrudu;
            ReturnValue.ChandraKendraGati = ChandraZeroYear.ChandraKendraGati;
            ReturnValue.SayanaCSudhaRahuvu = ChandraZeroYear.SayanaCSudhaRahuvu;
            if (ThousandDigit > 0)
            {
                ReturnValue.MadhyamaChandrudu += ChandraThousandYear[ThousandDigit - 1].MadhyamaChandrudu;
                ReturnValue.ChandraKendraGati += ChandraThousandYear[ThousandDigit - 1].ChandraKendraGati;
                ReturnValue.SayanaCSudhaRahuvu += ChandraThousandYear[ThousandDigit -1].SayanaCSudhaRahuvu;
            }
            if (HundredDigit > 0)
            {
                ReturnValue.MadhyamaChandrudu += ChandraHundredYear[HundredDigit - 1].MadhyamaChandrudu;
                ReturnValue.ChandraKendraGati += ChandraHundredYear[HundredDigit - 1].ChandraKendraGati;
                ReturnValue.SayanaCSudhaRahuvu += ChandraHundredYear[HundredDigit - 1].SayanaCSudhaRahuvu;
            }
            if (TensDigit > 0)
            {
                ReturnValue.MadhyamaChandrudu += ChandraTensYear[TensDigit - 1].MadhyamaChandrudu;
                ReturnValue.ChandraKendraGati += ChandraTensYear[TensDigit - 1].ChandraKendraGati;
                ReturnValue.SayanaCSudhaRahuvu += ChandraTensYear[TensDigit - 1].SayanaCSudhaRahuvu;
            }
            if (Digit > 0)
            {
                ReturnValue.MadhyamaChandrudu += ChandraDigitYear[Digit - 1].MadhyamaChandrudu;
                ReturnValue.ChandraKendraGati += ChandraDigitYear[Digit - 1].ChandraKendraGati;
                ReturnValue.SayanaCSudhaRahuvu += ChandraDigitYear[Digit - 1].SayanaCSudhaRahuvu;
            }
            ReturnValue.MadhyamaChandrudu.Refresh(); //Refreshes the value
            ReturnValue.ChandraKendraGati.Refresh(); //Refreshes the value
            ReturnValue.SayanaCSudhaRahuvu.Refresh(); //Refreshes the value
            return ReturnValue;
        }
        #endregion

    }
}
